<%@page contentType="text/html; charset=utf-8"%>
<%@ include file="../inc/TagLibs.jsp"%>
<c:set var="pageTitle" value="全部客户" />
<%@ include file="../inc/Title.jsp"%>
<head>
<link href="/css/Query.css" rel="stylesheet" type="text/css">
<link href="/calendar/dhtmlgoodies_calendar/dhtmlgoodies_calendar.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" type="text/css" href="/css/BillList.css" />
<c:if test="${currentUser.user.userType==1 || fn:indexOf(currentUser.privs,';NO_BUSI_COST;')==-1}">
	<c:set var="showCost" value="1" />
</c:if>
<script src="/js/QueryList.js"></script>
<script src="/js/popup_ext.js"></script>
<script src="/calendar/dhtmlgoodies_calendar/dhtmlgoodies_calendar.js"></script>
<script language="javascript">
	function doNew(){
		var url="/base/EstablishmentNew.ihtm?type=${type}";
		ShowIframe("客户",url,980,500,"refreshWin()");
	}
	function refreshWin(){
		window.location.reload(true);
	}
	function doEdit(id){
		var url="/base/EstablishmentEdit.ihtm?id="+id+"&type=${type}";
		ShowIframe("客户",url,980,500,"refreshWin()");
	}
	function doDelete(id){
		ShowConfirm('确认框','确定删除吗？',340,80,"doDelAct("+id+")");
	}
	function doDelAct(id){
		if(popRetVal!=null){
			var fromUrl=getFromUrl();
			window.location="/base/EstablishmentDelete.ihtm?id="+id+"&from_url="+fromUrl;
		}
	}
	function checkDateStr(){
		var startDate=document.getElementById("start_date").value;
		if(startDate==null || startDate==''){
			ShowAlert('提示框','请选择开始日期',200,100);
			return false;
		}else{
			var arr=startDate.split("-");
			if(arr.length==null || arr.length!=3){
				ShowAlert('提示框','开始日期格式不正确',200,100);
				return false;
			}else if(isNaN(arr[0]) || isNaN(arr[1]) || isNaN(arr[2])){
				ShowAlert('提示框','开始日期格式不正确',200,100);
				return false;
			}
		}
		var endDate=document.getElementById("end_date").value;
		if(endDate==null || endDate==''){
			ShowAlert('提示框','请选择结束日期',200,100);
			return false;
		}else{
			var arr=endDate.split("-");
			if(arr.length==null || arr.length!=3){
				ShowAlert('提示框','结束日期格式不正确',200,100);
				return false;
			}else if(isNaN(arr[0]) || isNaN(arr[1]) || isNaN(arr[2])){
				ShowAlert('提示框','结束日期格式不正确',200,100);
				return false;
			}
		}
		return true;
	}
	
	function createPageParaStr(){
		var str="start_date="+encodeURIComponent(document.getElementById("start_date").value);
		str=str+"&end_date="+encodeURIComponent(document.getElementById("end_date").value);
		str=str+"&search_key="+encodeURIComponent(document.getElementById("search_key").value);
		str=str+"&manager_name="+encodeURIComponent(document.getElementById("manager_name").value);
		str=str+"&phone="+encodeURIComponent(document.getElementById("phone").value);
		str=str+"&addr="+encodeURIComponent(document.getElementById("addr").value);
		str=str+"&mark="+encodeURIComponent(document.getElementById("mark").value);
		str=str+"&est_type="+document.getElementById("est_type").value;
		str=str+"&est_lev="+document.getElementById("est_lev").value;
		str=str+"&area_id="+document.getElementById("area_id").value;
		if(document.getElementById("ts_id")!=null){
			str=str+"&ts_id="+document.getElementById("ts_id").value;
		}
		var busi="";
		if(document.getElementById("busi1").checked){
			busi="1";
		}else if(document.getElementById("busi2").checked){
			busi="3";
		}else if(document.getElementById("busi3").checked){
			busi="6";
		}else if(document.getElementById("busi4").checked){
			busi="12";
		}
		str=str+"&busi="+busi;
		
		var comm="";
		if(document.getElementById("comm1").checked){
			comm="1";
		}else if(document.getElementById("comm2").checked){
			comm="3";
		}else if(document.getElementById("comm3").checked){
			comm="6";
		}else if(document.getElementById("comm4").checked){
			comm="12";
		}
		str=str+"&comm="+comm;
		return str;
	}
	function createProgramParaStr(){
		var str="start_date="+encodeURIComponent(document.getElementById("hid_start_date").value);
		str=str+"&end_date="+encodeURIComponent(document.getElementById("hid_end_date").value);
		str=str+"&search_key="+encodeURIComponent(document.getElementById("hid_search_key").value);
		str=str+"&manager_name="+encodeURIComponent(document.getElementById("hid_manager_name").value);
		str=str+"&phone="+encodeURIComponent(document.getElementById("hid_phone").value);
		str=str+"&addr="+encodeURIComponent(document.getElementById("hid_addr").value);
		str=str+"&mark="+encodeURIComponent(document.getElementById("hid_mark").value);
		str=str+"&est_type=${estType}";
		str=str+"&est_lev=${estLev}";
		str=str+"&area_id=${areaId}";
		str=str+"&ts_id=${tsId}";
		str=str+"&busi=${busi}";
		str=str+"&comm=${comm}";
		return str;
	}
	
	function doSearch(){
		var str="type=${type}";
		if(IsAdvSearch){//高级
			str=str+"&search_type=1";
			if(document.getElementById("cb_sk").checked){
				var searchKey=document.getElementById("search_key").value.trim();
				if(searchKey==null || searchKey==""){
					ShowAlert('提示框','请输入名称',200,100);
					return;
				}
				str=str+"&cb_sk=1";
			}
			if(document.getElementById("cb_busi").checked){
				str=str+"&cb_busi=1";
			}
			if(document.getElementById("cb_comm").checked){
				str=str+"&cb_comm=1";
			}
			if(document.getElementById("cb_manager")!=null){
				if(document.getElementById("cb_manager").checked){
					var managerName=document.getElementById("manager_name").value.trim();
					if(managerName==null || managerName==""){
						ShowAlert('提示框','请输入经办人姓名',200,100);
						return;
					}
					str=str+"&cb_manager=1";
				}
			}
			if(document.getElementById("cb_phone").checked){
				var phone=document.getElementById("phone").value.trim();
				if(phone==null || phone==""){
					ShowAlert('提示框','请输入电话',200,100);
					return;
				}
				str=str+"&cb_phone=1";
			}
			if(document.getElementById("cb_addr").checked){
				var addr=document.getElementById("addr").value.trim();
				if(addr==null || addr==""){
					ShowAlert('提示框','请输入地址',200,100);
					return;
				}
				str=str+"&cb_addr=1";
			}
			if(document.getElementById("cb_est_type").checked){
				var estType=document.getElementById("est_type").value;
				if(estType==null || estType=="" || estType=="0"){
					ShowAlert('提示框','请选择客户类别',200,100);
					return;
				}
				str=str+"&cb_est_type=1";
			}
			if(document.getElementById("cb_est_lev").checked){
				var estLev=document.getElementById("est_lev").value;
				if(estLev==null || estLev=="" || estLev=="0"){
					ShowAlert('提示框','请选择客户等级',200,100);
					return;
				}
				str=str+"&cb_est_lev=1";
			}
			if(document.getElementById("cb_mark").checked){
				var mark=document.getElementById("mark").value.trim();
				if(mark==null || mark==""){
					ShowAlert('提示框','请输入备注',200,100);
					return;
				}
				str=str+"&cb_mark=1";
			}
			if(document.getElementById("cb_area").checked){
				var areaId=document.getElementById("area_id").value;
				if(areaId==null || areaId=="" || areaId=="0"){
					ShowAlert('提示框','请选择地区',200,100);
					return;
				}
				str=str+"&cb_area=1";
			}
			if(document.getElementById("ts_id")!=null){
				if(document.getElementById("cb_ts").checked){
					var tsId=document.getElementById("ts_id").value;
					if(tsId==null || tsId=="" || tsId=="0"){
						ShowAlert('提示框','请选择账套',200,100);
						return;
					}
					str=str+"&cb_ts=1";
				}
			}
			if(document.getElementById("cb_cre_date").checked){
				if(checkDateStr()){
					str=str+"&cb_cre_date=1";
				}else{
					return;
				}
			}
		}else{//快速
			str=str+"&search_type=2";
		}
		var paraStr=createPageParaStr();
		if(paraStr!=""){
			str=str+"&"+paraStr;
		}
		window.location="/base/EstablishmentList.ihtm?"+str;
	}
	function getSearchCondition(){
		var searchType="${searchType}";
		var str="type=${type}&search_type="+searchType;
		if(searchType=="1"){//高级
			<c:if test="${cbSK=='1'}">str=str+"&cb_sk=1";</c:if>
			<c:if test="${cbManager=='1'}">str=str+"&cb_manager=1";</c:if>
			<c:if test="${cbPhone=='1'}">str=str+"&cb_phone=1";</c:if>
			<c:if test="${cbAddr=='1'}">str=str+"&cb_addr=1";</c:if>
			<c:if test="${cbMark=='1'}">str=str+"&cb_mark=1";</c:if>
			<c:if test="${cbEstType=='1'}">str=str+"&cb_est_type=1";</c:if>
			<c:if test="${cbEstLev=='1'}">str=str+"&cb_est_lev=1";</c:if>
			<c:if test="${cbArea=='1'}">str=str+"&cb_area=1";</c:if>
			<c:if test="${cbTs=='1'}">str=str+"&cb_ts=1";</c:if>
			<c:if test="${cbCreDate=='1'}">str=str+"&cb_cre_date=1";</c:if>
			<c:if test="${cbBusi=='1'}">str=str+"&cb_busi=1";</c:if>
			<c:if test="${cbComm=='1'}">str=str+"&cb_comm=1";</c:if>
		}else{//快速
			
		}
		
		var paraStr=createProgramParaStr();
		if(paraStr!=""){
			str=str+"&"+paraStr;
		}
		
		return str;
	}
	function doAutoCheck(objId){
		if(document.getElementById(objId).style.visibility!="hidden"){
			document.getElementById(objId).checked=true;
		}
	}
	function getFromUrl(){
		return encodeURIComponent(window.location);
	}
	function doGo(pageIndex){
		var str=getSearchCondition();
		window.location="/base/EstablishmentList.ihtm?"+str+"&current_page="+pageIndex;
	}
	function doJump(pageIndex){
		if(window.event.keyCode==13){
			doGo(pageIndex);
		}
	}
	function DoubleClick(it){
		var ob_arr = document.getElementsByName("query_checkbox");
		var str="";
		if(ob_arr.length>=it.getAttribute("index")){
			str=ob_arr[it.getAttribute("index")-1].value;
		}
		
		if(str==""){
			return;
		}
		doEdit(str);
	}
	function doCancel(){
		window.close();
	}
	function doInit(){
		//Window_Onload();
		document.getElementById("search_key").focus();
	}
	function checkInput(){
		if(window.event.keyCode==13){
			doSearch();
		}
	}
	function doDownload(){
		var str=getSearchCondition();
		window.location="/base/EstablishmentList.ihtm?content_type=EXCEL&"+str;
	}
	function doContactDownload(){
		var str=getSearchCondition();
		window.location="/base/EstablishmentContactDownload.ihtm?"+str;
	}
	function getMultiIds(){
		var ob_arr = document.getElementsByName("query_checkbox");
		var str="";
		for (i=0;i<ob_arr.length;i++){
			if ((ob_arr[i].checked == true)){
				if(str!=""){
					str=str+";";
				}
				str = str+ob_arr[i].value;
			}
		}
		return str;
	}
	function doRemove(){
		var ids=getMultiIds();
		if(ids==""){
			ShowAlert('提示框','请选择要移交的客户',200,100);
		}else{
			var url="/base/EstablishmentMoveForm.ihtm?est_type=CLIENT&type=MULTI&id_str="+ids;
			ShowIframeNoScroll("客户移交",url,340,210,"refreshWin()");
		}
	}
	function doCorporate(){
		var ids=getMultiIds();
		var idArr=ids.split(";");
		if(idArr.length<2){
			ShowAlert('提示框','请选择要合并的客户',200,100);
		}else{
			ShowConfirm('确认框','系统自动将选中的客户合并到最后交易的客户，重复的客户将被删除，是否确定？',340,80,"doCorporateAct('"+ids+"')");
		}
	}
	function doCorporateAct(ids){
		if(popRetVal!=null){
			var url="/base/EstablishmentCorporate.ihtm?type=CLIENT&id_str="+ids;
			ShowIframeNoScroll("客户合并中，请稍候...",url,200,200,"refreshWin()");
		}
	}
	function doChangeTs(){
		var ids=getMultiIds();
		if(ids==""){
			ShowAlert('提示框','请选择要改帐套的记录',200,100);
		}else{
			var url="/base/EstablishmentChangeTsForm.ihtm?type=CLIENT&id_str="+ids;
			ShowIframeNoScroll("改帐套",url,350,210,"refreshWin()");
		}
	}
	function doPriceList(estId){
		showWin(900,600,"/base/EstPriceListForEst.ihtm?est_type=CLIENT&est_id="+estId);
	}
	function showList(type,pra){
		var str="";
		if(type=='BUSI'){
			str="cb_busi=1&busi="+pra;
		}else if(type=='TYPE'){
			str="cb_est_type=1&est_type="+pra;
		}else{
			str="cb_est_lev=1&est_lev="+pra;
		}
		window.location="/base/EstablishmentList.ihtm?type=${type}&search_type=1&cb_ts=1&ts_id=DF_TS_ID&"+str;
	}
	function doLogList(estId){
		showWin(1024,600,"/base/EstablishmentLogList.ihtm?est_id="+estId);
	}
	<c:if test="${showCost=='1'}">
	function doReceiveList(estId){
		showWin(900,600,"/finance/ReceiveBillListForEstablishment.ihtm?id="+estId);
	}
	function doAdjustList(estId){
		showWin(900,600,"/finance/AdjustBillListForEstablishment.ihtm?id="+estId);
	}
	function doBusinessBillList(estId){
		showWin(900,600,"/business/BusinessBillListForEstablishment.ihtm?id="+estId);
	}
	function doBusinessItemList(estId){
		showWin(900,600,"/business/BusinessBillItemListForEstablishment.ihtm?id="+estId);
	}
	</c:if>
	function doAccessoryList(estId){
		showWin(900,600,"/business/AccessoryListForClient.ihtm?id="+estId);
	}
	function doComminucateList(estId){
		showWin(900,600,"/base/EstablishmentCommunicateList.ihtm?client_id="+estId);
	}
	function doAttachList(estId){
		showWin(900,600,"/base/AccessoryListForEstablishment.ihtm?est_id="+estId);
	}
	function doAttachNew(id){
		if(window.applicationCache){//html5
			ShowIframeNoScroll("附件","/business/AccessoryUpload.ihtm?agent_id="+id+"&agent_type=ESTABLISHMENT",560,320);
		}else{
			ShowIframeNoScroll("附件","/business/AccessoryNew.ihtm?agent_id="+id+"&agent_type=ESTABLISHMENT",560,320);
		}
	}
	function doSms(idStr){
		showWin(900,500,"/sms/SmsSendForm.ihtm?est_id_str="+idStr);
	}
	function doCal(clientId){
		var url="/base/EstablishmentCommunicateNew.ihtm?alert_type=NONE&client_id="+clientId;
		ShowIframe("日程",url,980,440,"");
	}
	function doPause(id,flag){
		var fromUrl=getFromUrl();
		window.location="/base/EstablishmentPause.ihtm?id="+id+"&flag="+flag+"&from_url="+fromUrl;
	}
</script>
</head>
<c:set var="smsFlag" value="0" />
<c:if test="${currentUser.user.userType==1 || fn:indexOf(currentUser.privs,';SMS_SEND_SIMP;')!=-1}"><c:set var="smsFlag" value="1" /></c:if>
<body oncontextmenu="return false">
<div class="Wrap"><!-- 页面主框架 -->
    
	<div id="ListContainer" class="Container"><!-- 主体容器 -->
	    
	    <!-- 标题栏 -->
	    <div class="Heading BillIcon">
	        <div class="HeadingContent">
	            <h1>全部客户</h1>
	            <span class="Note">管理所有客户资料，在这里可以定义每个固定客户的协议价格</span>
	        </div>
	    </div>
	
		<!-- 主内容 -->
		<div class="Content">
	        <!-- 筛选控件栏 -->
	        <div class="FilterBar ClearFix">
	            <div class="SearchIcon"></div>
	            <span class="fl">
	            	<table class="MoreOption" cellpadding="0" cellspacing="0">
	            		<th class="c1" width="80px">
	            			<input type="checkbox" name="cb_sk" id="cb_sk" <c:if test="${cbSK=='1' || searchType=='2'}">checked="true"</c:if> style="visibility:hidden;" />
	            			客户名称
	            		</th>
	            		<td class="c1" width="110px">
	            			<input type="text" class="TextBox" style="width:100px" id="search_key" name="search_key" onKeyUp="checkInput();" onFocus="doAutoCheck('cb_sk');" value="<c:out value="${searchKey}" />" title="以客户名称、客户拼音字头、客户编号进行模糊查询">
							<input type="hidden" id="hid_search_key" value="<c:out value="${searchKey}" />">
	            		</td>
	            	</table>
	            </span>
				<span class="fr">
	            	<a href="javascript:;" id="lnkMoreOption">更多查询选项</a>
		  			<input type="button" value=" 查 询" onClick="doSearch();" id="sSearchButton" name="sSearchButton" class="buttom search-but" title="以客户名称、客户拼音字头进行模糊查询">
					<c:if test="${currentUser.user.userType==1 || fn:indexOf(currentUser.privs,';BUSI_CLIE;')!=-1}">
						<input type="button" value=" 新 增" onClick="doNew();" id="sNewButton" name="sNewButton" class="buttom search-add">
					</c:if>
					<input type="button" value=" 导 出" onClick="doDownload();" id="sDownButton" name="sDownButton" class="buttom search-out" <c:if test="${currentUser.user.userType!=1 && fn:indexOf(currentUser.privs,';NO_EXPO;')!=-1}">disabled="true"</c:if>>
					<input type="button" value=" 移 交" onClick="doRemove();" id="sRemoveButton" name="sRemoveButton" class="buttom search-remo" <c:if test="${currentUser.user.userType!=1 && fn:indexOf(currentUser.privs,';CLIE_MOVE;')==-1}">disabled="true"</c:if> title="成批更改客户的经办人">
					<input type="button" value=" 合 并" onClick="doCorporate();" id="sCorporateButton" name="sCorporateButton" class="buttom search-corp" title="只有管理员admin账号才能进行合并操作。" <c:if test="${currentUser.user.userType!=1}">disabled="true"</c:if>>
					<input type="button" value=" 改帐套" onClick="doChangeTs();" id="sTsButton" name="sTsButton" class="buttom search-remo" title="只有管理员admin账号才能更改所属的账套。" <c:if test="${currentUser.user.userType!=1}">disabled="true"</c:if>>
	            </span>
				<div id="dvMoreOptionBox" class="MoreOptionBox" style="display:none;">
					<table class="MoreOption" cellpadding="0" cellspacing="0">
						<tr>
							<th class="c1" width="80px">
			        			<input type="checkbox" name="cb_phone" id="cb_phone" <c:if test="${cbPhone=='1'}">checked="true"</c:if>>
			        			电话
			        		</th>
			    			<td class="c1" width="240px">
			        			<input type="text" class="TextBox" maxlength="20" name="phone" id="phone" onKeyUp="checkInput();" onFocus="doAutoCheck('cb_phone');" value="<c:out value="${phone}" />">
								<input type="hidden" id="hid_phone" value="<c:out value="${phone}" />">
			    			</td>
			    			<th class="c2" width="80px">
			        			<input type="checkbox" name="cb_busi" id="cb_busi" <c:if test="${cbBusi=='1'}">checked="true"</c:if>>
			        			上次交易
			        		</th>
			    			<td class="c2" width="280px">
			        			<input type="radio" name="busi" id="busi1" onClick="doAutoCheck('cb_busi');" <c:if test="${busi==null || busi=='' || busi=='1'}">checked="true"</c:if>>1个月前
								<input type="radio" name="busi" id="busi2" onClick="doAutoCheck('cb_busi');" <c:if test="${busi=='3'}">checked="true"</c:if>>3个月前
								<input type="radio" name="busi" id="busi3" onClick="doAutoCheck('cb_busi');" <c:if test="${busi=='6'}">checked="true"</c:if>>半年前
								<input type="radio" name="busi" id="busi4" onClick="doAutoCheck('cb_busi');" <c:if test="${busi=='12'}">checked="true"</c:if>>一年前
			    			</td>
			    		</tr>
			    		<tr>
			    			<th class="c1">
			        			<input type="checkbox" name="cb_addr" id="cb_addr" <c:if test="${cbAddr=='1'}">checked="true"</c:if>></td>
			        			地址
			        		</th>
			        		<td class="c1">
			        			<input type="text" class="TextBox" maxlength="30" name="addr" id="addr" onKeyUp="checkInput();" onFocus="doAutoCheck('cb_addr');" value="<c:out value="${addr}" />">
								<input type="hidden" id="hid_addr" value="<c:out value="${addr}" />">
			    			</td>
							<th class="c2">
			        			<input type="checkbox" name="cb_comm" id="cb_comm" <c:if test="${cbComm=='1'}">checked="true"</c:if>>
			        			上次联系
			        		</th>
			    			<td class="c3">
			        			<input type="radio" name="comm" id="comm1" onClick="doAutoCheck('cb_comm');" <c:if test="${comm==null || comm=='' || comm=='1'}">checked="true"</c:if>>1个月前
								<input type="radio" name="comm" id="comm2" onClick="doAutoCheck('cb_comm');" <c:if test="${comm=='3'}">checked="true"</c:if>>3个月前
								<input type="radio" name="comm" id="comm3" onClick="doAutoCheck('cb_comm');" <c:if test="${comm=='6'}">checked="true"</c:if>>半年前
								<input type="radio" name="comm" id="comm4" onClick="doAutoCheck('cb_comm');" <c:if test="${comm=='12'}">checked="true"</c:if>>一年前
			    			</td>
						</tr>
						<tr>
			    			<th class="c1">
			        			<input name="" type="checkbox" name="cb_cre_date" id="cb_cre_date" <c:if test="${cbCreDate=='1'}">checked="true"</c:if> />
			        			创建日期
			        		</th>
			        		<td>
			        			<input type="text" class="TextBox Datetime" maxlength="15" onKeyUp="checkInput();" onFocus="doAutoCheck('cb_cre_date');" id="start_date" name="start_date" value="<c:out value="${startDate}" />">
								<img src="/images/calendar.gif" class="imgIconButton" onClick="displayCalendar(document.getElementById('start_date'),'yyyy-mm-dd',this,false,'doAutoCheck(\'cb_cre_date\')');">
								<input type="hidden" id="hid_start_date" value="<c:out value="${startDate}" />">
					           	 至
								<input type="text" class="TextBox Datetime" maxlength="15" onKeyUp="checkInput();" onFocus="doAutoCheck('cb_cre_date');" id="end_date" name="end_date" value="<c:out value="${endDate}" />">
								<img src="/images/calendar.gif" class="imgIconButton" onClick="displayCalendar(document.getElementById('end_date'),'yyyy-mm-dd',this,false,'doAutoCheck(\'cb_cre_date\')');">
								<input type="hidden" id="hid_end_date" value="<c:out value="${endDate}" />">
			    			</td>
							<th class="c2">
			        			<input type="checkbox" name="cb_est_type" id="cb_est_type" <c:if test="${cbEstType=='1'}">checked="true"</c:if>>
			        			客户类别
			        		</th>
			    			<td class="c3">
			        			<select name="est_type" id="est_type" onFocus="doAutoCheck('cb_est_type');">
					  				<option value="0">==全部类别==</option>
									<c:forEach var="item" items="${estTypeList}">
									<option value="${item.id}" <c:if test="${estType==item.id}">selected</c:if>>${item.typeName}</option>
									</c:forEach>
					  			</select>
			    			</td>
						</tr>
						<tr>
			    			<th class="c1">
			        			<input type="checkbox" name="cb_manager" id="cb_manager" <c:if test="${cbManager=='1'}">checked="true"</c:if>>
			        			经办人
			        		</th>
			        		<td class="c1">
			        			<input type="text" class="TextBox" maxlength="15" name="manager_name" id="manager_name" onKeyUp="checkInput();" onFocus="doAutoCheck('cb_manager');" value="<c:out value="${managerName}" />">
								<input type="hidden" id="hid_manager_name" value="<c:out value="${managerName}" />">
			    			</td>
							<th class="c2">
			        			<input type="checkbox" name="cb_est_lev" id="cb_est_lev" <c:if test="${cbEstLev=='1'}">checked="true"</c:if>>
			        			客户等级
			        		</th>
			    			<td class="c3">
			        			<select name="est_lev" id="est_lev" onFocus="doAutoCheck('cb_est_lev');">
					  				<option value="0">==全部等级==</option>
									<c:forEach var="item" items="${estLevelList}">
									<option value="${item.id}" <c:if test="${estLev==item.id}">selected</c:if>>${item.levelName}</option>
									</c:forEach>
					  			</select>
			    			</td>
						</tr>
						<tr>
							<th class="c1">
			        			<input type="checkbox" name="cb_mark" id="cb_mark" <c:if test="${cbMark=='1'}">checked="true"</c:if>></td>
			        			备注
			        		</th>
			        		<td class="c1">
			        			<input type="text" class="TextBox" maxlength="30" name="mark" id="mark" onKeyUp="checkInput();" onFocus="doAutoCheck('cb_mark');" value="<c:out value="${mark}" />">
								<input type="hidden" id="hid_mark" value="<c:out value="${mark}" />">
			    			</td>
			        		<th class="c2">
			        			<input type="checkbox" name="cb_area" id="cb_area" <c:if test="${cbArea=='1'}">checked="true"</c:if>>
		          				地区
			        		</th>
	                    	<td class="c3">
	                    		<select name="area_id" id="area_id" onFocus="doAutoCheck('cb_area');">
									<option value="0">==全部地区==</option>
									<commonTag:createSelectTree list="${areaList}" emptyOption="0" justEnabled="1" defaultValue="${areaId}" />
								</select>
	                    	</td>
						</tr>
						<c:if test="${checkTs=='Y'}">
						<tr>
							<th class="c1">
			        			<input type="checkbox" name="cb_ts" id="cb_ts" <c:if test="${cbTs=='1'}">checked="true"</c:if>>
	                        	账套
			        		</th>
			    			<td class="c1">
			        			<select name="ts_id" id="ts_id" onFocus="doAutoCheck('cb_ts');">
				    				<option value="0">==请选择账套==</option>
				    				<c:forEach var="item" items="${myTsList}">
									<option value="${item.id}" <c:if test="${tsId==item.id}">selected</c:if>>${item.title}</option></c:forEach>
								</select>
			        		</td>
			        		<th class="c2">&nbsp;</th>
	                    	<td class="c3">&nbsp;</td>
						</tr>
						</c:if>
					</table>
					
					<div class="OptionOrderBy">
						<span class="fr"><a href="javascript:;" id="lnkHiddenOption">隐藏查询选项</a></span>
	                </div>
				</div>
			</div>
			
			<!-- 提示信息显示栏 -->
	        <div class="MsgBar">
	            <%@include file="../inc/AlertMsg.jsp"%>
	        </div>

			<!-- 上栏 分页、操作等 -->
	        <div class="TopToolBar">
	            <table class="ListNoteInfo" cellpadding="0" cellspacing="0">
	            	<tr>
	                	<td>
	                		客户数：${qr.totalCount}&nbsp;&nbsp;
	                		选择：
	                		上次交易（
						  	<a href="javascript:showList('BUSI','1');">1个月前</a>
						  	<a href="javascript:showList('BUSI','3');">3个月前</a>
						  	<a href="javascript:showList('BUSI','6');">半年前</a>
						  	<a href="javascript:showList('BUSI','12');">一年前</a>
						  	）
						  	<c:forEach var="item" items="${estTypeList}">
						  		<a href="javascript:showList('TYPE',${item.id});">${item.typeName}</a>
						  	</c:forEach>
						  	<c:forEach var="item" items="${estLevelList}">
						  		<a href="javascript:showList('LEVEL',${item.id});">${item.levelName}</a>
						  	</c:forEach>
						</td>
	            	</tr>
	            </table>
			</div>
			
			<div class="table-list">
		        <table width="100%">
		          	<tr>
						<th width="14"><input type="checkbox" onClick="javascript:checkall(this);"></th>
						<th width="6%">类别</th>
						<th width="10%">名称</th>
						<th width="10%">地址</th>
						<th width="10%">电话</th>
						<th width="6%">联系人</th>
						<th width="6%">帐套</th>
						<th width="6%">经办人</th>
						<th width="8%">最近联系</th>
						<th width="8%">最近交易</th>
						<th width="10%">备注</th>
						<th width="12%">相关记录</th>
						<th width="8%" >操作</th>
					</tr>
					<c:forEach var="item" items="${qr.list}" varStatus="i">
					<c:if test="${(i.index mod 2)==0}"><c:set var="trClass" value="query_list_data_tr1" /></c:if>
					<c:if test="${(i.index mod 2)!=0}"><c:set var="trClass" value="query_list_data_tr2" /></c:if>
					<c:if test="${item.establishment.status=='Y'}"><c:set var="defaultFontColor" value="#000000" /></c:if>
					<c:if test="${item.establishment.status=='N'}"><c:set var="defaultFontColor" value="red" /></c:if>
					<tr class="${trClass}" style="color:${defaultFontColor};cursor:pointer;" defaultFontColor="${defaultFontColor}" index="${i.index+1}" ondblclick='javascript:DoubleClick(this)' onClick='javascript:ClickCheck(this,true)' onmouseout='javascript:mouseout(this)' onmouseover='javascript:mouseover(this)'>
						<td ><input type="checkbox" onClick="javascript:ClickCheck(this,true);" name='query_checkbox' value="${item.establishment.id}"></td>
						<td ><commonTag:showSimpleObjectName list="${estTypeList}" objectId="${item.establishment.estTypeId}" /></td>
						<td >${item.establishment.estName}</td>
						<td >${item.establishment.address}</td>
						<td >${item.establishment.phone}</td>
						<td >${item.establishment.linkman}</td>
						<td><commonTag:showSimpleObjectName list="${tsList}" objectId="${item.establishment.tallySetId}" /></td>
						<td >${item.establishment.managerName}</td>
						<td><c:if test="${item.establishment.commTime!=null}"><fmt:formatDate value="${item.establishment.commTime}" pattern="yyyy-MM-dd"/></c:if></td>
						<td><c:if test="${item.establishment.busTime!=null}"><fmt:formatDate value="${item.establishment.busTime}" pattern="yyyy-MM-dd"/></c:if></td>
						<td >${item.establishment.mark}</td>
						<td style="text-align:left">
							<c:if test="${showCost=='1'}"><a href="javascript:doBusinessBillList('${item.establishment.id}');"></c:if>订单<c:if test="${showCost=='1'}"></a></c:if>
							<c:if test="${showCost=='1'}"><a href="javascript:doReceiveList('${item.establishment.id}');"></c:if>收款<c:if test="${showCost=='1'}"></a></c:if>
							<c:if test="${showCost=='1'}"><a href="javascript:doAdjustList('${item.establishment.id}');"></c:if>调账<c:if test="${showCost=='1'}"></a></c:if>
							<br>
							<c:if test="${showCost=='1'}"><a href="javascript:doBusinessItemList('${item.establishment.id}');"></c:if>订货明细<c:if test="${showCost=='1'}"></a></c:if>&nbsp;
							<a href="javascript:doAccessoryList('${item.establishment.id}');">图样</a>
							<br>
							<a href="javascript:doComminucateList('${item.establishment.id}');">联系记录</a>&nbsp;
							<a href="javascript:doAttachList('${item.establishment.id}');">附件</a>
							<br>
							<a href="javascript:doLogList('${item.establishment.id}');">修改历史</a>
							<c:if test="${currentUser.user.userType==1 || fn:indexOf(currentUser.privs,';CLIE_PRIC;')!=-1}"><a href="javascript:doPriceList('${item.establishment.id}');"></c:if>项目价格<c:if test="${currentUser.user.userType==1 || fn:indexOf(currentUser.privs,';CLIE_PRIC;')!=-1}"></a></c:if>
						</td>
						<td>
							<a href="javascript:doEdit('${item.establishment.id}');">查看</a>
							<a href="javascript:doAttachNew('${item.establishment.id}');">传附件</a>
							<br>
							<c:if test="${smsFlag=='1'}"><a href="javascript:doSms('${item.establishment.id}');"></c:if>短信<c:if test="${smsFlag=='1'}"></a></c:if>
							<a href="javascript:doCal('${item.establishment.id}');">写日程</a>
							<br>
							<c:if test="${item.establishment.status=='Y'}"><a href="javascript:doPause('${item.establishment.id}','N');">停用</a></c:if>
							<c:if test="${item.establishment.status=='N'}"><a href="javascript:doPause('${item.establishment.id}','Y');">启用</a></c:if>
							<a href="javascript:doDelete('${item.establishment.id}');">删除</a>
						</td>
					</tr>
					</c:forEach>
				</table>
			</div>

			<!-- 底栏 分页、操作等 -->
	        <div class="BottomToolBar ClearFix">
			    <%@include file="../inc/Pages.jsp"%>
	        </div>
			
		</div>
	</div>
</div>
</body>
</html>
<script type="text/javascript">
	function ChangeWindowSize( container, maxWidth ){
	    setTimeout( function(){
	        var w1 = document.documentElement.clientWidth-40;
	        if( w1>maxWidth ) w1 = maxWidth;
	        else if( w1<980 ) w1 = 970;
	        container.style.width = w1+'px';
	    }, 300 );
	}
	var IsAdvSearch = false;
	(function(){
		doInit();
	    var ListContainer = document.getElementById('ListContainer');
	    ChangeWindowSize( ListContainer, 2020 );    // 超过 1280 的最大 1260 ，不全部铺满
	
	    var lnkMoreOption   = document.getElementById('lnkMoreOption');
	    var lnkHiddenOption = document.getElementById('lnkHiddenOption');
	    lnkMoreOption.onclick = function(){
	    	IsAdvSearch = true;
	        document.getElementById('dvMoreOptionBox').style.display = 'block';
	        document.getElementById('cb_sk').style.visibility = 'visible';
	        this.style.visibility = 'hidden';
	    };
	    lnkHiddenOption.onclick = function(){
	    	IsAdvSearch = false;
	        document.getElementById('dvMoreOptionBox').style.display = 'none';
	        document.getElementById('cb_sk').style.visibility = 'hidden';
	        lnkMoreOption.style.visibility = 'visible';
	    };
	})();
</script>
